//
//  MyViewController.m
//  ReciteBook
//
//  Created by xuziyuan on 13-12-20.
//  Copyright (c) 2013年 student. All rights reserved.
//

#import "MyViewController.h"
#import "AddContentViewController.h"

@interface MyViewController ()

@property (nonatomic,strong) NSArray *array;
@end

@implementation MyViewController

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
        [self addObserver:self forKeyPath:@"idUser" options:NSKeyValueObservingOptionNew context:nil];
        
    }
    return self;
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.tableView reloadData];
}

- (void)viewDidLoad
{
    [super viewDidLoad];


    self.myAppDelegate=(AppDelegate *)[[UIApplication sharedApplication] delegate];
    self.title=@"我的";
    UIBarButtonItem *rightBtn=[[UIBarButtonItem alloc] initWithTitle:@"注销" style:UIBarButtonItemStylePlain target:self action:@selector(cancel)];
    self.navigationItem.rightBarButtonItem=rightBtn;
    
    self.array=@[@"个人信息",@"功能"];

}

//注销用户
-(void)cancel
{
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{

    return 2;
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    return self.array[section];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{

    if (section==0) {
        return 2;
    }else{
        return 1;
    }
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell==nil) {
        cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    if (indexPath.section==0&&indexPath.row==0) {
        cell.textLabel.text=@"用户ID:";
        cell.detailTextLabel.text=@"";
    }else if (indexPath.section==0&&indexPath.row==1){
        cell.textLabel.text=@"用户名:";
        cell.detailTextLabel.text=@"";
    }else{
        cell.textLabel.text=@"增加新诗歌";
        cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
    }
    
    return cell;
}



#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row==0&&indexPath.section==1) {
        AddContentViewController *addVC=[[AddContentViewController alloc] initWithNibName:@"AddContentViewController" bundle:nil];
        [self.navigationController pushViewController:addVC animated:YES];
    }

}

@end
